<style lang="scss" scoped>
  .containers {
    /*如果不设置本行，qq浏览器的padding-right不生效*/
    display: flex;
    flex-direction: column;
    padding: 10px;

    p {
      font-size: 18px;
      color: #11263C;
      border-left: 3px solid rgba(84, 91, 245, 1);
      padding-left: 10px;
      margin-bottom: 15px;
    }

    /*搜索区域*/
    .el-form {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      border-radius: 10px;
      background: #fff;
      box-shadow: 0px 20px 45px rgba(240, 237, 246, 0.5);
      padding: 10px 20px 0 20px;
      margin: 0 10px 20px 10px;

      .el-form-item {
        margin-bottom: 10px;

        ::v-deep .el-form-item__label {
          font-size: 14px;
          font-weight: 400;
          line-height: 32px;
          color: rgba(3, 2, 2, 1);
          text-align: right;
        }

        ::v-deep .el-form-item__content {
          .el-input {
            width: 165px;

            .el-input__inner {
              width: 165px;
              border: 1px solid rgba(127, 127, 213, 0.5);
              border-radius: 10px;
            }
          }

          .el-button {
            height: 32px;
            border-radius: 2px;
            background: linear-gradient(268.09deg, rgba(96, 103, 250, 1) 0%, rgba(119, 153, 252, 1) 100%);
            padding: 8px 18px;
            color: #fff;
            border: none;
            margin-left: 25px;

            &:hover {
              border: none;
              background: linear-gradient(268.09deg, rgb(69, 78, 255) 0%, rgb(88, 130, 255) 100%);
            }

            &:nth-child(1) {
              width: 60px;
              height: 32px;
              opacity: 1;
              border-radius: 2px;
              background: rgba(242, 243, 245, 1);
              color: rgba(0, 0, 0, 0.3);
              padding: 8px 16px;

              &:hover {
                border: none;
                background: rgb(228, 228, 228);
              }
            }
          }
        }
      }
    }

    /*统计区域*/
    .card-bg {
      display: flex;
      justify-content: space-around;
      align-items: center;
      height: 180px;
      background: #fff;
      border-radius: 10px;
      padding: 0 10px;

      .quarter-r {
        .money {
          display: block;
          font-size: 24px;
          font-weight: 500;
          line-height: 28px;
          color: rgba(3, 2, 2, 1);
          text-align: right;
          margin-bottom: 20px;
        }

        .desc {
          display: block;
          font-size: 14px;
          font-weight: 400;
          line-height: 16px;
          color: rgba(188, 195, 212, 1);
          text-align: right;
        }
      }
    }

    .sale {
      background: #fff;
      border-radius: 10px;
      padding: 15px 30px;
      box-sizing: border-box;

      p {
        font-size: 18px;
        font-weight: 400;
        line-height: 28px;
        color: rgba(17, 38, 60, 1);
        border-left: 4px solid #545BF5;
      }

      .bar {
        width: 100%;
      }
    }

    .mb20 {
      margin-bottom: 20px;
    }
  }
</style>

<template>
  <div class="containers">
    <!--<p>交易汇总报表</p>-->

    <!--搜索区域-->
    <el-form size="small" :inline="true" label-width="70px">
      <el-form-item label="选择时间" prop="orderDate">
        <el-input/>
      </el-form-item>

      <el-form-item label="选择时间" prop="orderDate">
        <el-input/>
      </el-form-item>

      <el-form-item style="display: flex;">
        <el-button size="mini">重置</el-button>
        <el-button type="primary" size="mini">筛选</el-button>
        <el-button type="danger" size="mini">刷1新</el-button>
      </el-form-item>
    </el-form>

    <!--统计第一排-->
    <el-row style="margin: 0;" :gutter="20">
      <!--左侧-->
      <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12" :span="12">

        <el-row :gutter="20">
          <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12" class="mb20">
            <div class="card-bg">
              <el-progress type="circle" :percentage="100" :stroke-width="10" color="#563BFF"
                           define-back-color="#EFECFF"></el-progress>
              <div class="quarter-r">
                <span class="money">￥{{saleAndExpend && saleAndExpend.obtainDailySalesProfit }}</span> <span
                class="desc">今日销售利润</span>
              </div>
            </div>
          </el-col>
          <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12" class="mb20">
            <div class="card-bg">
              <el-progress type="circle" :percentage="100" :stroke-width="10" color="#FF7049 "
                           define-back-color="#FFF3F0"></el-progress>
              <div class="quarter-r">
                <span class="money">￥{{saleAndExpend &&saleAndExpend.dailySalesAmount || 0}}</span> <span class="desc">今日收号支出</span>
              </div>
            </div>
          </el-col>
        </el-row>

        <!--第二行-->
        <el-row :gutter="20">
          <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12" class="mb20">
            <div class="card-bg">
              <el-progress type="circle" :percentage="100" :stroke-width="10" color="#499DFF"
                           define-back-color="#D2E7FF"></el-progress>
              <div class="quarter-r">
                <span class="money">￥{{saleAndExpend &&saleAndExpend.obtainThePreviousDaysProfit || 0}}</span> <span
                class="desc">昨日销售利润</span>
              </div>
            </div>
          </el-col>
          <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12" class="mb20">
            <div class="card-bg">
              <el-progress type="circle" :percentage="100" :stroke-width="10" color="#9236FF"
                           define-back-color="#F6ECFF"></el-progress>
              <div class="quarter-r">
                <span class="money">￥{{saleAndExpend &&saleAndExpend.salesAmountFromThePreviousDay || 0}}</span> <span
                class="desc">昨日收号支出</span>
              </div>
            </div>
          </el-col>
        </el-row>
      </el-col>

      <!--右侧-->
      <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12" :span="12" class="mb20">
        <div class="sale">
          <p>近7日销售看板</p>
          <div class="bar">
            <sevenSaleEcharts v-if="sevenDays" id="1" :data="sevenDays.salesDashboardForThePast7Days"/>
          </div>
        </div>
      </el-col>
    </el-row>

    <!--统计第二排-->
    <el-row :gutter="20" style="margin: 0;">
      <!--左侧-->
      <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12" class="mb20">
        <div class="sale">
          <p>近7日销售利润看板</p>
          <div class="bar">
            <sevenSaleEcharts v-if="sevenDays" id="2" :data="sevenDays.profitDashboardForThePast7Days"/>
          </div>
        </div>
      </el-col>

      <!--右侧-->
      <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
        <div class="sale">
          <p>近7日回收看板</p>
          <div class="bar">
            <sevenSaleEcharts v-if="sevenDays" id="3" :data="sevenDays.recyclingBillboardsInThePast7Days"/>
          </div>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
    import {getSevenDaySalesAmount, getFinancialStatements} from "../../api/business/home";
    import sevenSaleEcharts from "./components/sevenSaleEcharts";

    export default {
        components: {sevenSaleEcharts},
        data() {
            return {
                searchParams: {
                    strTate: '',
                    endTate: ''
                },
                saleAndExpend: undefined,
                sevenDays: undefined,//七日数据
            }
        },
        created() {
            this.getData();
        },
        methods: {
            // 销售、支出
            getData() {
                getFinancialStatements(this.searchParams).then(res => {
                    this.saleAndExpend = res.data;
                })

                getSevenDaySalesAmount().then(res => {
                    this.sevenDays = res.data;
                })
            }
        }
    }
</script>
